package com.bjwl.service.impl;

import com.bjwl.dao.ServiceProjectMapper;
import com.bjwl.pojo.Partment;
import com.bjwl.pojo.ServiceProject;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.ServiceProjectService;
import com.bjwl.utils.Log4jUtils;
import com.bjwl.utils.PageBean;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/7 9:56
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class ServiceProjectServiceImpl implements ServiceProjectService {

    @Autowired
    private ServiceProjectMapper serviceProjectMapper;

    @Override
    public PageBean<ServiceProject> serviceList(BasicQueryVo vo) {
        PageBean<ServiceProject> pageBean = new PageBean<ServiceProject>(vo.getPageNum(),10,serviceProjectMapper.getTotalRecord(vo));
        pageBean.setData(serviceProjectMapper.findAllServiceProject(pageBean,vo));
        return pageBean;
    }

    @Override
    public boolean addService(ServiceProject serviceProject) {

            serviceProjectMapper.addServiceProject(serviceProject);
            return true;

    }

    @Override
    public ServiceProject editStart(Integer id) {
        return serviceProjectMapper.findServiceProjectById(id);
    }

    @Override
    public boolean updateServiceProject(ServiceProject serviceProject) {

            Integer state = serviceProjectMapper.updateServiceProject(serviceProject);
            return true;

    }

    @Override
    public boolean deleteServiceProject(Integer id) {
        try {
            serviceProjectMapper.deleteServiceProject(id);
            return true;
        }catch (Exception e){
            Log4jUtils.LITERAL3.getLog().error(e.getMessage());
        }
        return false;
    }
}
